package cn.jg.framework.common.exception;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors;

/**
 * Created by luowei on 2018/12/6.
 */
@AllArgsConstructor
public enum ImportType {
    //-1.未知 1.知识库 2.资料库
    NONE(-1),
    SOLUTION(1),        //解决方案
    KNOWLEDGEITEM_EXCEL(2),//知识点
    EXAM_QUESTION(3),
    SENSITIVE_WORDS(4), //敏感词
    SYNONYM_WORDS(5),//同义词
    TEMPLATE_KNOWLEDGEITEM(6),//模板知识点
    KNOWLEDGEITEM_DOC(7),
    USEFUL_EXPRESSION(8),
    USEFUL_LINK(9)
    ;
    private @Getter int value;

    private final static Map<Integer, ImportType> typeMap = Arrays.stream(ImportType.values()).collect(Collectors.toMap(t -> t.value, t -> t));

    public static ImportType valueOf(Integer value){
        return Optional.ofNullable(typeMap.get(value)).orElse(NONE);
    }
}
